#include "SStates.h"

//user结构体的函数
#if(1)
int SUserStatesInit(SUserStates* this_user)
{
    memset(&(this_user->mUserName[0]),0,sizeof(this_user->mUserName));
    memset(&(this_user->mPassword[0]),0,sizeof(this_user->mPassword));
    this_user->mLevel = 0;
    this_user->mIsLogined = 0;
    return 1;
}

int SUserStatesGetLevel(SUserStates* this_user)
{
    if(this_user->mIsLogined)
        return this_user->mLevel;
    else
        return 0;

    return 0;
}

int SUserStatesCopy(SUserStates* from,SUserStates* to)
{
    SUserStatesInit(to);
    strcpy(to->mUserName,from->mUserName);
    strcpy(to->mPassword,from->mPassword);
    to->mLevel = from->mLevel;
    to->mIsLogined = from->mIsLogined;
    return 0;
}
#endif//user 结构体函数结束

//Serve 结构体的函数
#if(1)
int SServeStateInit(SServeState* this_serve)
{
    memset(&(this_serve->mServeAddrIn),0,sizeof(this_serve->mServeAddrIn));
    this_serve->mServeSocket = -1;
    this_serve->mCanConnected =  0;
    this_serve->mIsOpened = 0;
    return 1;
}
#endif


//Client 结构体的函数
#if(1)
int SClientStateInit(SClientStates* this_client)
{
    memset(&(this_client->mLocalDir[0]),0,sizeof(this_client->mLocalDir));
    memset(&(this_client->mNetDir[0]),0,sizeof(this_client->mNetDir));
    this_client->mIsWorking = 1;
    return 1;
}
#endif
//states 结构体的函数
#if(1)
int SStatesInit(SStates* this_states)
{
    SServeStateInit(&(this_states->mServeStates));
    SUserStatesInit(&(this_states->mUserStates));
    SClientStateInit(&(this_states->mClientStates));
    return 1;
}

int SStatesIsClientWorking(SStates* this_states)
{
    return this_states->mClientStates.mIsWorking;
}

#endif
